package hlhj.fhp.burst

import android.content.Context
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.bumptech.glide.Priority
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.request.RequestOptions

/**
 * Created by Administrator on 2018\6\11 0011.
 */
object GlideUtil {
    fun loadHeadOption(): RequestOptions {
        return RequestOptions()
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .error(R.drawable.ic_bl_touxiang)
                .placeholder(R.drawable.ic_bl_touxiang)
                .priority(Priority.IMMEDIATE)
    }

    fun loadImageOption(): RequestOptions {
        return RequestOptions()
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .priority(Priority.IMMEDIATE)
    }

    fun loadImg(context:Context,url:String?,img:ImageView?){
        url?.let {
            if (it.contains("http")){
                Glide.with(context).load(url).apply(loadImageOption()).into(img!!)
            }else{
                Glide.with(context).load(Contents.PUBLICK_URL+url).apply(loadImageOption()).into(img!!)

            }
        }

    }
}